﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using ClientMobile.SSVService;
using googlemaps;
namespace UniversityGuide
{
    public partial class msg : PhoneApplicationPage
    {
        Singleton s = Singleton.Instance;
        public msg()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            //  try
            //{
            base.OnNavigatedTo(e);
            string selectedIndex = "";
            if (NavigationContext.QueryString.TryGetValue("email", out selectedIndex))
            {  
                textBox1.Text = selectedIndex;
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml" , UriKind.Relative));
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (textBox1.Text == "" && textBox2.Text == "" && textBox3.Text == "")
            { MessageBox.Show("Remplir les champs"); }
            else
            {
                Service1SoapClient serv = new Service1SoapClient();
                serv.envoyer_emailCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(serv_envoyer_emailCompleted);
                serv.envoyer_emailAsync(s.Chauff.Email, textBox2.Text, textBox1.Text, textBox3.Text);
            }
        }

        void serv_envoyer_emailCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            MessageBox.Show("Email Envoyé avec succès ");
        }

    }

}